package cuishifeng.blog.learn.concurrent.threadLocal;

/**
 * @author cuishifeng <cuishifeng0207@163.com> Created on 2021-03-26
 */
public class ThreadLocalDemo {

    // public static ThreadLocal<String> threadLocal = new ThreadLocal();

    public static ThreadLocal<String> threadLocal = new InheritableThreadLocal<>();

    public static void childThread() {
        threadLocal.set("hello");
        new Thread(new Runnable() {
            @Override
            public void run() {
                String value = threadLocal.get();
                System.out.println(value);
            }
        }).start();
    }


    public static void main(String[] args) {

        childThread();

        ThreadLocal<String> threadLocal = new ThreadLocal<>();
        threadLocal.set("hello");
        threadLocal.get();
    }
}
